package com.invite.me.ui.cehualan;

import android.content.Intent;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.invite.me.R;
import com.invite.me.base.BaseActivity;
import com.invite.me.beans.presenter.InvitationCodePresenter;
import com.invite.me.beans.res.YaoQingmaShouBean;
import com.invite.me.util.QRCodeUtil;
import com.invite.me.wlqq.Contract;

public class InvitationCodeActivity  extends BaseActivity implements View.OnClickListener,Contract.BaseView{
    InvitationCodePresenter invitationCodePresenter;
    private ImageView erweima;

    @Override
    protected void initView() {
        invitationCodePresenter=new InvitationCodePresenter(this);
        invitationCodePresenter.yanzhengma();
        ImageView imagefanhui= findViewById(R.id.imagefanhui);
        TextView tuiguangjilu= findViewById(R.id.tuiguangjilu);
        erweima = findViewById(R.id.erweima);
        imagefanhui.setOnClickListener(this);
        tuiguangjilu.setOnClickListener(this);

    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.imagefanhui:
                finish();
                break;
            case R.id.tuiguangjilu:
                Intent yqjl=new Intent(InvitationCodeActivity.this,YqjlActivity.class);
                startActivity(yqjl);


                break;

        }

    }
    @Override
    protected int getActivityLayoutId() {
        return R.layout.activity_invitationcode;
    }

    @Override
    protected void loadData() {

    }


    @Override
    public void setPresenter(Contract.BasePresenter basePresenter) {

    }

    @Override
    public void onDataSucess(Object o)  {
        if(o instanceof YaoQingmaShouBean){

            YaoQingmaShouBean yaoQingmaShouBean= (YaoQingmaShouBean) o;
            if(yaoQingmaShouBean.getCode()==1000){
                String data = yaoQingmaShouBean.getData();
                Bitmap qrCodeBitmap = QRCodeUtil.createQRCodeBitmap(data, 541, 541);
                if (qrCodeBitmap != null) {
                    erweima.setImageBitmap(qrCodeBitmap);
                }

            }


        }

    }

    @Override
    public void onDataFaile(Object o) {

    }

    @Override
    public void onComplete() {

    }
}
